package com.yuanian.timingwheel.redis;

import com.yuanian.timingwheel.context.SpringContext;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.core.SetOperations;

public class RedisSet<T> {

    private String key;
    private SetOperations<String, T> setOperations;

    public RedisSet(String key) {
        this.key = "htliu-job:" + key;
        this.setOperations = ((RedisTemplate) SpringContext.getBean("redisTemplate")).opsForSet();
    }
    public void add(T v) {
        this.setOperations.add(this.key, v);
    }

    public boolean contains(T v) {
        return this.setOperations.isMember(this.key, v);
    }
}
